home *** CD-ROM | disk | FTP | other *** search
- /* AddAmiNetFileList.br
- *
- * Arexx script to add a AmiNet RECENT/INDEX list to the database.
- *
- * Based on AddAmiNetFileList.br v3.1 provided by the THOR team.
- *
- * Modified by Henrik Dissing to handle dates and file sizes correctly.
- *
- */
-
- options results
- /* trace results */
-
- parse arg argument
-
- template = 'BBSNAME/A,FILENAME/A'
-
- if(argument = '' | argument = '?') then
- do
- say '$VER: AddAminetFileList.br V3.2 (15.10.95)'
- say 'Template:' template
- exit
- end
-
- if ~show('p', 'BBSREAD') then do
- address command
- "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
- "WaitForPort BBSREAD"
- end
-
- address BBSREAD
-
- READARGS template ARGS CMDLINE argument
- if(rc ~= 0) then
- do
- say BBSREAD.LASTERROR
- exit
- end
-
- if(~OPEN(fh,ARGS.FILENAME,'Read')) then
- do
- say 'Unable to open file'
- exit
- end
-
- rc = 0
- signal on ERROR
- signal on BREAK_C
- signal on HALT
-
- BUFMODE COPYBACK /* Enable copyback buffer mode */
-
- aline = readln(fh)
- ltype = word(aline, 2)
- ldate = word(aline, words(aline))
-
- parse var ldate day '-' month '-' year
- day = right(day, 2, '0')
- select
- when month == 'Jan' then month = '01'
- when month == 'Feb' then month = '02'
- when month == 'Mar' then month = '03'
- when month == 'Apr' then month = '04'
- when month == 'May' then month = '05'
- when month == 'Jun' then month = '06'
- when month == 'Jul' then month = '07'
- when month == 'Aug' then month = '08'
- when month == 'Sep' then month = '09'
- when month == 'Oct' then month = '10'
- when month == 'Nov' then month = '11'
- when month == 'Dec' then month = '12'
- otherwise
- say "Unexpected month identifier in header:" month
- goto HALT
- end
- year = right(year, 2, '0')
- if year < 95 then
- year = '20'year
- else
- year = '19'year
- ldate = date('i', year || month || day, 's') * 86400
-
- do until eof(fh)
- aline = readln(fh)
-
- do while(left(aline, 1) = '|')
- aline = readln(fh)
- end
-
- if (aline == "") then iterate
-
- if ltype == "Complete" then
- do
- parse var aline 1 fname 20 farea 31 fsize 36 fage 40 fdesc
- fname = strip(fname)
- farea = strip(farea)
- fsize = strip(fsize)
- fdate = ldate - (strip(fage, 'B', ' +') * 7 * 86400)
- fdesc = strip(fdesc)
- end
- else if ltype == "Recent" then
- do
- parse var aline 1 fname 20 farea 31 fsize 36 fdesc
- fname = strip(fname)
- farea = strip(farea)
- fsize = strip(fsize, 'B', ' +')
- fdate = ldate
- fdesc = strip(fdesc)
- end
- else
- do
- say "Unexpected format of first line in" ARGS.FILENAME
- goto HALT
- end
-
- if right(fsize, 1) == 'M' then mega = 1
- else mega = 0
- fsize = compress(fsize, 'KM')
-
- if ~datatype(fsize,'N') then fsize = 0
-
- if mega == 1 then
- fsize = trunc(fsize * 1024.0)
- fsize = fsize * 1024
-
- say left(aline, 30)
-
- CONFIGFAREA '"' || ARGS.BBSNAME || '"' farea
-
- if(fdesc ~= '') then
- do
- drop BRFILE.
-
- BRFILE.NAME = fname
- BRFILE.SIZE = fsize
- BRFILE.DATE = fdate
-
- BRFILE.DESCRIPTION.COUNT = 1
- BRFILE.DESCRIPTION.1 = fdesc
-
- WRITEBRFILE '"' || ARGS.BBSNAME || '"' farea stem BRFILE
-
- end
- end
-
- ERROR:
- HALT:
- BREAK_C:
-
- if(rc ~= 0) then
- do
- say 'Error' rc 'in line' SIGL ':' BBSREAD.LASTERROR
- end
-
- BUFMODE ENDCOPYBACK /* Disable copyback buffer mode */
-
- exit
-